package com.qf.courtesycard.mqcustomer.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qf.courtesyard.domain.entity.Ticket;
import com.qf.courtesycard.mqcustomer.entity.Userforticket;
import com.qf.courtesycard.mqcustomer.esvo.UserforticketLogsVo;
import com.qf.courtesycard.mqcustomer.fegin.TicketClient;
import com.qf.courtesycard.mqcustomer.mapper.UserforticketMapper;
import com.qf.courtesycard.mqcustomer.repositroy.TicketLogsRepositroy;
import com.qf.courtesycard.mqcustomer.service.IUserforticketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author lx
 * @since 2023-03-10
 */
@Service
public class UserforticketServiceImpl extends ServiceImpl<UserforticketMapper, Userforticket> implements IUserforticketService {

    @Autowired
    private TicketLogsRepositroy ticketLogsRepositroy;
    @Autowired
    private TicketClient ticketClient;

    @Override
    public void saveTicketLogs(Userforticket userforticket) throws Exception {
        if (userforticket == null) {
            throw new Exception("日志信息为空");
        }
        //调用provide updateticket接口 修改ticket抢票状态
        Ticket ticket = new Ticket();
        ticket.setStatus(1);
        ticket.setId(userforticket.getTicketId());
        ticketClient.updateTicket(ticket);
        save(userforticket);
    }

    @Override
    public void saveTicketLogsEs(UserforticketLogsVo userforticketLogsVo) throws Exception {
        if (userforticketLogsVo == null) {
            throw new Exception("日志信息为空");
        }
        ticketLogsRepositroy.save(userforticketLogsVo);
    }
}
